package tw.rescue.dao.impl.slim3;

import org.slim3.datastore.Datastore;

import tw.rescue.dao.CategoryDao;
import tw.rescue.model.slim3.meta.CategoryMeta;
import tw.rescue.model.slim3.model.Category;

import com.google.appengine.api.datastore.Key;

public class Slim3CategoryDaoImpl extends Slim3BaseDaoImpl implements CategoryDao<Key> {

	@Override
	public Category getCategory(Key key) {
		return Datastore.getOrNull(CategoryMeta.get(), key);
	}

	@Override
	public Category getCategory(String label) {
		CategoryMeta meta = CategoryMeta.get();
		return Datastore.query(meta).filter(meta.label.equal(label)).asSingle();
	}

	@Override
	public Category get(Key key) {
		return getCategory(key);
	}
}
